#!/usr/bin/env python
# -*- coding: utf-8 -*-
# @Time    : 2020/11/22 11:54
# @USER    : Shengji He
# @File    : ValidAnagram.py
# @Software: PyCharm
# @Version  : Python-
# @TASK:
from collections import Counter


class Solution:
    def isAnagram(self, s: str, t: str) -> bool:
        """
        Given two strings s and t , write a function to determine if t is an anagram of s.

        Example 1:
            Input: s = "anagram", t = "nagaram"
            Output: true
        Example 2:
            Input: s = "rat", t = "car"
            Output: false
        Note:
            You may assume the string contains only lowercase alphabets.

        Follow up:
            What if the inputs contain unicode characters? How would you adapt your solution to such case?

        :param s:
        :param t:
        :return:
        """
        return Counter(s) == Counter(t)

    def isAnagram2(self, s, t):
        return abs(sum([ord(x) ** 0.5 for x in s]) - sum([ord(y) ** 0.5 for y in t])) < 1e-5


if __name__ == '__main__':
    func = Solution()
    s = "anagram"
    t = "nagaram"
    print(func.isAnagram(s, t))
    print(func.isAnagram2(s, t))
    print('done')
